package com.paopao.role.control;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.paopao.System.annotation.ArchivesLog;
import com.paopao.role.pojo.Role;
import com.paopao.role.server.RoleServer;

import net.sf.json.JSONObject;

@Controller
@RequestMapping("role")
public class RoleControl
{
	@Autowired
	RoleServer roleServer;
	@RequestMapping("query")
	@ArchivesLog(operationType="显示:",operationName="显示role") 
	public void query(HttpServletResponse response,String limit, String offset) throws IOException{
		List<Role> data=roleServer.query();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("total", data.size());//
		map.put("rows", data);//
		JSONObject jsonArray = JSONObject.fromObject(map);
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(jsonArray.toString());
	}

}
